import unittest
from game.actions.models import action, attack
from game.monster.models import individual
from game.monster.tests import basicTest
from game.damage.models import damageType

class ActionTest(basicTest):
    def setUp(self):
        basicTest.setUp(self)
        self.action = action.objects.create(name = "TestAction", getSuccessMethod='alwaysHit', successMethod='testHit',
                             failureMethod='fail', attemptMessage="Attempting to Hit", successMessage="Successfully hit")
        #self.action.actionPackage='game.actions.tests'
        self.caller = individual.objects.create(species = self.species)
        self.target = individual.objects.create(species = self.species, totalHP=100)
        self.dt = damageType.objects.create(name = "Test")
        self.attack = attack.objects.create(name = "TestAttack", getSuccessMethod="alwaysHit", successMethod="testHit",
                                            failureMethod='fail', attemptMessage="Attempting to Hit", successMessage="Successfully hit",
                                            damageType= self.dt)
           
    def tearDown(self):
        basicTest.tearDown(self)
        action.delete(self.action)
        individual.delete(self.caller)
        individual.delete(self.target)
        attack.delete(self.attack)
        damageType.delete(self.dt)
        
    def testAction(self):
        self.assertEquals(self.action.getResults(self.caller, self.target), self.action.successMessage)
        
    def testAttackAction(self):
        print self.target.totalHP
        
    def testSubclass(self):
        x = action.objects.filter(id = self.attack.id)[0]
        print type(x)
        